package thinkingInJava.enumerated;

//: enumerated/EnumClass.java
//Capabilities of the Enum class
import static thinkingInJava.YTool.YPrint.*;

enum Shrubbery { GROUND, CRAWLING, HANGING }

public class EnumClass {
	public static void main(String[] args) {
		for(Shrubbery s : Shrubbery.values()) {
			print(s + " ordinal: " + s.ordinal());
			printnb(s.compareTo(Shrubbery.CRAWLING) + " ");
			printnb(s.equals(Shrubbery.CRAWLING) + " ");
			print(s == Shrubbery.CRAWLING);
			print(s.getDeclaringClass());
			print(s.name());
			print("----------------------");
		}
		// Produce an enum value from a string name:
		for(String s : "HANGING CRAWLING GROUND GROUNd".split(" ")) {
			Shrubbery shrub = Enum.valueOf(Shrubbery.class, s);
			print(shrub);
		}
	}
} /* Output:
GROUND ordinal: 0
-1 false false
class Shrubbery
GROUND
----------------------
CRAWLING ordinal: 1
0 true true
class Shrubbery
CRAWLING
----------------------
HANGING ordinal: 2
1 false false
class Shrubbery
HANGING
----------------------
HANGING
CRAWLING
GROUND
Exception in thread "main" java.lang.IllegalArgumentException: No enum constant enumerated.Shrubbery.GROUNd
	at java.lang.Enum.valueOf(Enum.java:238)
	at enumerated.EnumClass.main(EnumClass.java:22)
 *///:~
